package com.yanqu.road.server.cmd.strongholdwar.wild;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.strongholdwar.CrossStrongholdMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_STRONGHOLD_WAR_WILD_MOVE,desc = "野外据点门客移动")
public class CrossPatronsMoveWildCmd extends CrossUnionCommand {
    private long userId;
    private int nextWildId;
    private int activityId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossMoveToStrongholdReqMsg reqMsg = StrongholdWarProto.CrossMoveToStrongholdReqMsg.parseFrom(packet.getBytes());
        nextWildId = reqMsg.getId();
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ret = CrossStrongholdMgr.move(activityId,nextWildId,serverId,userId);
        StrongholdWarProto.CrossMoveToStrongholdRespMsg.Builder msg = StrongholdWarProto.CrossMoveToStrongholdRespMsg.newBuilder();
        msg.setRet(ret);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_STRONGHOLD_WILD_MOVE, msg);
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
